﻿using DualReferralClient.Entity;
using DualReferralClient.Model;
using MetroFramework.Forms;
using System;
using System.Windows.Forms;

namespace DualReferralClient
{
    public partial class LoginForm : MetroForm
    {
        private DualReferralModel dualReferralClient = new DualReferralModel();

        public LoginForm()
        {
            InitializeComponent();
            TypeComboBox.SelectedIndex = 0;
            this.FormBorderStyle = FormBorderStyle.None;//无边框
        }

        private void LoginButton_Click(object sender, EventArgs e)
        {
            string code = LoginTextBox.Text;
            string passWord = PassWordTextBox.Text;
            try
            {
                YSCode YSCode = dualReferralClient.getLoginInfo(code, passWord);
                GlobalVar.KSCode = YSCode.KSCode;
                GlobalVar.KSName = YSCode.KSName;
                GlobalVar.YSCode = YSCode.code;
                GlobalVar.YSName = YSCode.name;
                if (TypeComboBox.Text.Equals("住院"))
                {
                    GlobalVar.type = "zy";
                }
                else
                {
                    GlobalVar.type = "mz";
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("账号或密码错误请重新输入");
            }
        }

        private void OKButton_Click(object sender, System.EventArgs e)
        {
            

        }

        private void ExitButton_Click(object sender, System.EventArgs e)
        {
            System.Environment.Exit(0);
        }
    }
}
